]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
brightnessManager: Use slider as bias when auto brightness is being used
authorSebastian Wick <sebastian.wick@redhat.com>
Mon, 20 Oct 2025 11:38:37 +0000 (13:38 +0200)
committerSebastian Wick <sebastian.wick@redhat.com>
Thu, 30 Oct 2025 13:30:22 +0000 (14:30 +0100)
The code previously tried to ensure that the sliders were disabled when
auto brightness was active, and determine the brightness just from the
auto brightness target we get from g-s-d.

It turns out that users do want to still have some control over the
brightness, even if auto brightness is active.

The slider is now being used as a bias for the auto brightness target
instead.

This also means that we can drop the BrightnessScale::locked property.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3935>

js/misc/brightnessManager.js
js/ui/status/brightness.js

index eb4ad1b4615bceb06375bb6bd6fb2ad9d0f0d5ae..8ac347785eca60f24bf9b95ec9d88aade344e156 100644 (file)
@@ -236,14 +236,20 @@ export const BrightnessManager = GObject.registerClass({
                 this._showOSD(this._monitorScales.values());
         }
 
-        // ensure we lock the global scale when auto brightness is in control
-        this._globalScale.locked = this._abTarget >= 0.0;
-
         // Update the actual backlight according to the new monitor brightnesses
         // and other factors, such as dimming.
         for (const scale of this._monitorScales.values()) {
+            // If auto brightness is active (_abTarget >= 0) we use the scale
+            // as a bias for the auto brightness target to determine the target
+            // brightness.
+            // Otherwise the target brightness just comes from the scale.
+            const target = this._abTarget >= 0.0
+                ? Math.clamp(this._abTarget + scale.value - 0.5, 0.0, 1.0)
+                : scale.value;
+
+            // the actual brightness is then determined by clipping to the
+            // dimming target, if dimming is enabled
             const max = this._dimmingEnabled ? this._dimmingTarget : 1.0;
-            const target = this._abTarget >= 0.0 ? this._abTarget : scale.value;
             const brightness = Math.min(max, target);
 
             scale.setBacklight(brightness);
@@ -273,10 +279,6 @@ export const BrightnessScale = GObject.registerClass({
             'value', null, null,
             GObject.ParamFlags.READWRITE,
             0, 1.0, 1.0),
-        'locked': GObject.ParamSpec.boolean(
-            'locked', null, null,
-            GObject.ParamFlags.READWRITE,
-            false),
     },
 }, class BrightnessScale extends GObject.Object {
     constructor(name, value = 1.0, nSteps = SCALE_VALUE_N_STEPS) {
@@ -284,7 +286,6 @@ export const BrightnessScale = GObject.registerClass({
 
         this._name = name;
         this._value = value;
-        this._locked = false;
         this._nSteps = nSteps;
     }
 
@@ -300,17 +301,6 @@ export const BrightnessScale = GObject.registerClass({
         this._setValue(value);
     }
 
-    get locked() {
-        return this._locked;
-    }
-
-    set locked(locked) {
-        if (this._locked === locked)
-            return;
-        this._locked = locked;
-        this.notify('locked');
-    }
-
     get nSteps() {
         return this._nSteps;
     }
index 2ca09f34215469b8aaf7e175ad2861fe9f7d4a4d..bee51155a31eb47e7ae98f7fb8d5f2145a458778 100644 (file)
@@ -50,13 +50,6 @@ class BrightnessItem extends QuickSlider {
 
         this._manager = Main.brightnessManager;
         this._manager.connectObject('changed',
-            this._onManagerChanged.bind(this), this);
-        this._onManagerChanged();
-    }
-
-    _onManagerChanged() {
-        this._manager.globalScale?.disconnectObject(this);
-        this._manager.globalScale?.connectObject('notify::locked',
             this._sync.bind(this), this);
         this._sync();
     }
@@ -64,7 +57,7 @@ class BrightnessItem extends QuickSlider {
     _sync() {
         const {globalScale} = this._manager;
         this.set({
-            visible: globalScale && !globalScale.locked,
+            visible: globalScale,
             menuEnabled: this._manager.scales.length > 1,
         });